package com.shop.mapper;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.shop.pojo.pms.Pms_Sku_Sale_Attr_Value;
import com.shop.vo.SkuItemSaleAttrVo;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

//sku销售值
public interface Pms_Sku_Sale_Value_Mapper extends BaseMapper<Pms_Sku_Sale_Attr_Value> {

    //查询spu下的全部销售属性
    List<SkuItemSaleAttrVo> getSaleAttrsBySpuId(@Param("spuId") Long spuId);
    //根据分类来查询当前分类下的全部销售属性
    @Select("select attr_id,attr_name,group_concat(distinct attr_value) as attr_value from pms_sku_sale_attr_value ${ew.customSqlSegment}")
    List<Pms_Sku_Sale_Attr_Value> getSkuSaleValueByCatelogId(@Param("ew") Wrapper<Pms_Sku_Sale_Attr_Value> queryWrapper);
    //根据商品的skuID查询商品的属性&值
    @Select("select GROUP_CONCAT(attr_value SEPARATOR '-') from pms_sku_sale_attr_value\n" +
            "where sku_id = #{skuId}")
    List<String> get_web_Sku_Sale_Values(@Param("skuId") Long skuId);
}
